package ktwl.code;

import com.alibaba.fastjson.JSONObject;
import ktwl.code.connection.JdbcConnection;
import ktwl.code.utils.DbHandle;
import ktwl.code.utils.DbUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Test
 *
 * @author Name on 2019/8/21 15:49
 * @version 1.0
 */
public class Test {

    static{
        JdbcConnection.init("com.mysql.cj.jdbc.Driver",
                "jdbc:mysql://139.159.190.0:3306/Erecord_Dev?characterEncoding=utf8&useSSL=false&useAffectedRows=true&serverTimezone=GMT%2B8",
                "root",
                "ktwlrjcs2018");
    }

    public static void main(String...args){
//        //无参数查询
//        List<JSONObject> objects = null;
//        try {
//            objects = DbUtil.noGinsengQuery("SELECT \n" +
//                    "ap.`archive_name`,ap.`borrow_code`,it.`id` AS tId,ap.`borrow_means`,it.`id`,it.`borrow_apply_id`,it.`record_name`\n" +
//                    "FROM `dagl_t_ere_borrow_item` it\n" +
//                    "LEFT JOIN `dagl_t_ere_borrow_apply` ap ON ap.`id` = it.`borrow_apply_id`\n" +
//                    "WHERE it.`borrow_apply_id` = 7848091143812472832");
//        }catch (Exception e){
//            e.printStackTrace();
//            DbUtil.connectionPoolClose();
//        }
//        for(JSONObject jsonObject:objects){
//            System.out.println(jsonObject);
//        }
//        DbUtil.connectionPoolClose();

        //带参数查询
//        List<JSONObject> objects = null;
//        try {
//            List<String> strings = new ArrayList<>();
//            strings.add("borrow_code");
//            strings.add("tId");
//            strings.add("id");
//            objects = DbUtil.parameterQuery("SELECT \n" +
//                    "ap.`archive_name`,ap.`borrow_code`,it.`id` AS tId,ap.`borrow_means`,it.`id`,it.`borrow_apply_id`,it.`record_name`\n" +
//                    "FROM `dagl_t_ere_borrow_item` it\n" +
//                    "LEFT JOIN `dagl_t_ere_borrow_apply` ap ON ap.`id` = it.`borrow_apply_id`\n" +
//                    "WHERE it.`borrow_apply_id` = 7848091143812472832",strings);
//        }catch (Exception e){
//            e.printStackTrace();
//            DbUtil.connectionPoolClose();
//        }
//        for(JSONObject jsonObject:objects){
//            System.out.println(jsonObject);
//        }
//        DbUtil.connectionPoolClose();

//        //删除
//        String s = "DELETE FROM dagl_t_customer_info WHERE id = 123423412431";
//        Integer b = 0;
//        try {
//            b = DbUtil.operationData(s);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//        System.out.println(b);
//        DbUtil.connectionPoolClose();

//        //修改
//        String s = "UPDATE dagl_t_customer_info SET cpu_num = \"xcvxcvxcvx\",message = \"ccvv\" WHERE id = 123423412431";
//        Integer b = 0;
//        try {
//            b = DbUtil.operationData(s);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//        System.out.println(b);
//        DbUtil.connectionPoolClose();

//        //新增
//        String s = "INSERT INTO dagl_t_customer_info (id,cpu_num,message)VALUES(\"123423412431\",\"asdfas\",\"adsf\")";
//        Integer b = 0;
//        try {
//            b = DbUtil.operationData(s);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//        System.out.println(b);
//        DbUtil.connectionPoolClose();

//        //建表
//        String s = "CREATE TABLE `fund_record` (\n" +
//                "  `f_code` BIGINT(30) NOT NULL COMMENT '主键:收据单号',\n" +
//                "  `amount` DECIMAL(10,0) DEFAULT '0' COMMENT '转账金额(万元)',\n" +
//                "  `balance_amount` DECIMAL(10,0) DEFAULT '0' COMMENT '结算金额',\n" +
//                "  `dn_code` VARCHAR(100) COLLATE utf8_bin DEFAULT NULL COMMENT '划款单号',\n" +
//                "  `fund_out_check` BIT(1) DEFAULT b'0' COMMENT '出账对账:true.已对账,false.未对账',\n" +
//                "  `fund_out_check_oper_id` VARCHAR(30) COLLATE utf8_bin DEFAULT NULL COMMENT '对账人Id',\n" +
//                "  `fund_out_check_oper_name` VARCHAR(30) COLLATE utf8_bin DEFAULT NULL COMMENT '对账人姓名',\n" +
//                "  `fund_out_check_time` DATETIME DEFAULT NULL COMMENT '对账时间',\n" +
//                "  `fundin_check` BIT(1) DEFAULT b'0' COMMENT '入账对账:true.已对账,false.未对账',\n" +
//                "  `fundin_check_oper_id` VARCHAR(50) COLLATE utf8_bin DEFAULT NULL COMMENT '对账人id',\n" +
//                "  `fundin_check_oper_name` VARCHAR(50) COLLATE utf8_bin DEFAULT NULL COMMENT '对账人姓名',\n" +
//                "  `fundin_check_time` DATETIME DEFAULT NULL COMMENT '对账时间',\n" +
//                "  `fundin_flow` VARCHAR(30) COLLATE utf8_bin DEFAULT NULL COMMENT '缴款流水号',\n" +
//                "  `fundin_time` DATETIME DEFAULT NULL COMMENT '入账时间',\n" +
//                "  `in_bank_name` VARCHAR(200) COLLATE utf8_bin DEFAULT NULL COMMENT '转入银行',\n" +
//                "  `in_card_name` VARCHAR(100) COLLATE utf8_bin DEFAULT NULL COMMENT '收款人姓名',\n" +
//                "  `in_card_num` VARCHAR(50) COLLATE utf8_bin DEFAULT NULL COMMENT '转入账号',\n" +
//                "  `is_balance` BIT(1) DEFAULT b'0' COMMENT '是否结算',\n" +
//                "  `out_bank_name` VARCHAR(200) COLLATE utf8_bin DEFAULT NULL COMMENT '转出银行',\n" +
//                "  `out_card_name` VARCHAR(100) COLLATE utf8_bin DEFAULT NULL COMMENT '缴款人姓名',\n" +
//                "  `out_card_num` VARCHAR(50) COLLATE utf8_bin DEFAULT NULL COMMENT '转出账号',\n" +
//                "  `payin_flag` VARCHAR(30) COLLATE utf8_bin DEFAULT NULL COMMENT '缴款标志',\n" +
//                "  `print_count` TINYINT(4) DEFAULT '0' COMMENT '凭证打印次数',\n" +
//                "  `ts_code` BIGINT(30) DEFAULT NULL COMMENT '交易编号',\n" +
//                "  PRIMARY KEY (`f_code`)\n" +
//                ") ENGINE=INNODB DEFAULT CHARSET=utf8 COLLATE=utf8_bin";
//        Integer b = 0;
//        try {
//            b = DbUtil.operationData(s);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//        System.out.println(b);
//        DbUtil.connectionPoolClose();
    }
}